﻿using MOKA.TPM.Application.Enum;
using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 数据字典明细
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("SysDictDetail", "数据字典明细")]
public class SysDictDetail
{
    /// <summary>
    /// 主键Id
    /// </summary>
    [SugarColumn(ColumnName = "Id", ColumnDescription = "", IsPrimaryKey = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 字典目录
    /// </summary>
    [SugarColumn(ColumnName = "DictCodeID", ColumnDescription = "字典目录")]
    public Guid? DictCodeID { get; set; }

    /// <summary>
    /// 项目值（代码）
    /// </summary>
    [SugarColumn(ColumnName = "ItemValue", ColumnDescription = "项目值（代码）", Length = 50)]
    [Required, MaxLength(50)]
    public string ItemValue { get; set; } = string.Empty;

    /// <summary>
    /// 项目名称
    /// </summary>
    [SugarColumn(ColumnName = "ItemName", ColumnDescription = "项目名称", Length = 200)]
    [Required, MaxLength(200)]
    public string ItemName { get; set; } = string.Empty;

    /// <summary>
    /// 附加名称2
    /// </summary>
    [SugarColumn(ColumnName = "ItemName2", ColumnDescription = "附加名称2", Length = 200)]
    [MaxLength(200)]
    public string? ItemName2 { get; set; }

    /// <summary>
    /// 附加名称3
    /// </summary>
    [SugarColumn(ColumnName = "ItemName3", ColumnDescription = "附加名称3", Length = 200)]
    [MaxLength(200)]
    public string? ItemName3 { get; set; }

    /// <summary>
    /// 附加名称4
    /// </summary>
    [SugarColumn(ColumnName = "ItemName4", ColumnDescription = "附加名称4", Length = 200)]
    [MaxLength(200)]
    public string? ItemName4 { get; set; }

    /// <summary>
    /// 项名备注
    /// </summary>
    [SugarColumn(ColumnName = "ItemRemark", ColumnDescription = "项名备注", Length = 30)]
    [MaxLength(30)]
    public string? ItemRemark { get; set; }

    /// <summary>
    /// 排序序号
    /// </summary>
    [SugarColumn(ColumnName = "FN_Order", ColumnDescription = "排序序号")]
    public int FNOrder { get; set; }

    /// <summary>
    /// 父项
    /// </summary>
    [SugarColumn(ColumnName = "ItemParent", ColumnDescription = "父项")]
    public Guid? ItemParent { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [SugarColumn(ColumnName = "Status", ColumnDescription = "状态")]
    public TpmStatusEnum Status { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "创建人", Length = 20)]
    [MaxLength(20)]
    public string? CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    [SugarColumn(ColumnName = "UpdateUser", ColumnDescription = "修改人", Length = 20)]
    [MaxLength(20)]
    public string? UpdateUser { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTime", ColumnDescription = "修改时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 是否已删除
    /// </summary>
    [SugarColumn(ColumnName = "IsDelete", ColumnDescription = "是否已删除")]
    public bool IsDelete { get; set; }

    /// <summary>
    /// DictCodeID (字典目录) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(DictCodeID), nameof(SysDictCode.Id))]//多对一
    public SysDictCode sysDictCode_DictCodeID { get; set; }

    /// <summary>
    /// ItemParent (父项) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ItemParent), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_ItemParent { get; set; }

    /// <summary>
    /// CreateUser (创建人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }

    /// <summary>
    /// UpdateUser (修改人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UpdateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UpdateUser { get; set; }

    /// <summary>
    /// 子表：系统字典目录
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(SysDictCode.Id))]//一对多
    public List<SysDictCode> SysDictCodes { get; set; }

    /// <summary>
    /// 子表：数据字典明细
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(SysDictDetail.ItemParent))]//一对多
    public List<SysDictDetail> SysDictDetails { get; set; }
}